﻿#include "Dialog_SetLoadMode.h"
#include "ui_Dialog_SetLoadMode.h"

Dialog_SetLoadMode::Dialog_SetLoadMode(QWidget *parent) :
  QDialog(parent),
  ui(new Ui::Dialog_SetLoadMode)
{
  ui->setupUi(this);
  setFixedSize(size());
  updateLoadMode();
  connect(ui->pushButton_confirm,&QPushButton::clicked,this,&Dialog_SetLoadMode::accept);
  connect(ui->pushButton_cancel,&QPushButton::clicked,this,&Dialog_SetLoadMode::reject);
}

Dialog_SetLoadMode::~Dialog_SetLoadMode()
{
  delete ui;
}

void Dialog_SetLoadMode::accept()
{
  if(ui->radioButton_loaded->isChecked())
    {
      load=true;
    }
  else
    {
      load=false;
    }
  QDialog::accept();
}

void Dialog_SetLoadMode::reject()
{
  updateLoadMode();
  QDialog::reject();
}

bool Dialog_SetLoadMode::isLoad()
{
  return load;
}

void Dialog_SetLoadMode::updateLoadMode()
{
  if(load)
    {
      ui->radioButton_loaded->setChecked(true);
      ui->radioButton_unloaded->setChecked(false);
    }
  else
    {
      ui->radioButton_loaded->setChecked(false);
      ui->radioButton_unloaded->setChecked(true);
    }
}

bool Dialog_SetLoadMode::getLoad()
{
  return load;
}

Dialog_SetLoadMode* Dialog_SetLoadMode::setLoad(bool load)
{
  this->load=load;
  updateLoadMode();
  return this;
}
